<!-- 单条搜索页面 -->
<template>
	<view class="card">
		<view class="item" v-for="(item, index) in resultData" :key="item.id"
			@tap="$Router.push({url:'/pages/scan/details', query:{id: item.id}})">
			<view class="u-flex text-grey u-m-b-10">
				<view class="t1">序号</view>
				<view class="t2">防伪码</view>
				<view class="t3">规格型号</view>
				<view class="t4">查询结果</view>
			</view>
			<view class="u-flex">
				<view class="t1">{{ index+1 }}</view>
				<view class="t2">{{ item.security_code }}</view>
				<view class="t3">{{ item.parameter }}</view>
				<view class="t4">
					<text class="text-green" v-if="item.result  === 1">官方正品</text>
					<text class="text-red" v-else>查无此码</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'results',
		data() {
			return {
				qrcode: [],
				resultData: []
			};
		},
		onHide() {},
		onLoad() {
			if(this.$Route.query.qrcode){
				this.qrcode.push(this.$Route.query.qrcode);
			}
			this.search();
		},
		methods: {
			search() {
				let that = this;
				that.$http(
					'goods.inquireSearch',
					{
						qrcode: that.qrcode
					},
					'获取查询结果中...'
				).then(res => {
					if (res.code === 1) {
						that.resultData = res.data.list;
					}
					that.$u.toast(res.msg);
				});
			}
		}
	};
</script>

<style lang="scss">
	.item {
		position: relative;
		padding: 30rpx 0;
		font-size: 25rpx;

		&:first-child {
			padding-top: 0;
		}

		&:last-child {
			padding-bottom: 0;
		}

		&:not(:last-child)::after {
			content: '';
			display: block;
			position: absolute;
			bottom: 0;
			left: 0;
			width: 100%;
			height: 2rpx;
			background-color: rgba(33, 32, 30, .05);
		}

		.t1 {
			width: 12%;
		}

		.t2 {
			width: 28%;
		}

		.t3 {
			width: 40%;
		}

		.t4 {
			width: 20%;
		}
	}
</style>